home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 June
/
EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso
/
earcd
/
comm2
/
mmstrtrk.lha
/
MM
/
Rexx
/
CheckWildcard.rexx
next >
Wrap
OS/2 REXX Batch file
|
1995-06-24
|
2KB
|
115 lines
/* RH 24.06.95 */
parse arg addr from to .
addr = strip(addr)
from = replace(strip(from), '*', '#?')
to = replace(strip(to), '*', '#?')
if addr='' | from='' | to='' then
do
say 'Usage: [RX] CheckWildcard[.rexx] <address> <from-pattern> <to-pattern>'
say
exit
end
address 'MAILMANAGER'
if Check_Pattern(from, addr)=0 then
do
say
say 'The from-pattern "'from'" does not match with address "'addr'".'
say
exit
end
say
new = Resolve_Wildcard(addr, from, to)
say
say addr 'will be remapped to' new
say
exit
Check_Pattern: procedure Expose result
arg pattern, string.0
string.count = 1
result. = 0
MM_SearchInStem 'string' 'result' pattern 'STR'
result = result.0
return result.count>0
Log: procedure
parse arg text
say text
return
Replace: procedure
parse arg string,new,old
do while index(string, old)~=0
interpret "parse var string l '"old"' r"
string = l || new || r
end
return string
Resolve_Wildcard: procedure
parse arg address, from, to
parse var address a.1 ':' a.2 '/' a.3 '.' a.4 '@' a.5
parse var from f.1 ':' f.2 '/' f.3 '.' f.4 '@' f.5
parse var to t.1 ':' t.2 '/' t.3 '.' t.4 '@' t.5
do n=1 to 5
wposf = pos('*', f.n)
wpost = pos('*', t.n)
select
when wposf=0 & wpost=0 then r.n = t.n
when wposf>0 & wpost=0 then r.n = f.n
when wposf>0 & wpost>0 then
do
dpos = compare(f.n, t.n)
if dpos=0 then tmp = ''
else tmp = substr(t.n, dpos, wpost-dpos)
r.n = left(f.n, max(dpos-1, 0)) || tmp || substr(a.n, wposf)
end
otherwise
do
call Log('*** WILDCARD-ERROR: Unable to resolve' f.n '->' t.n '('from '->' to')')
call Log(' Remap NOT possible!')
do m=1 to 5
r.m = a.m
end
leave n
end
end
end
return r.1':'r.2'/'r.3'.'r.4'@'r.5